home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / WPRINTS.C < prev    next >
Text File  |  1990-01-16  |  3KB  |  68 lines

  1. /**********************************************************/
  2. /* File Id.                  Wprints.C.                   */
  3. /* Author.                   Stan Milam.                  */
  4. /* Date Written.             03/06/89.                    */
  5. /*                                                        */
  6. /*          (c) Copyright 1989-90 by Stan Milam           */
  7. /*                                                        */
  8. /* Comments: This function will write a string to a spec- */
  9. /* fied window using a different color than what is saved */
  10. /* with the window.  Again, if a window is overlapped it  */
  11. /* is "floated" to the top.  The string will not be print-*/
  12. /* ed outside of the window's boundries.                  */
  13. /**********************************************************/
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <dos.h>
  19. #include "pcw.i"
  20. #include "pcwproto.h"
  21.  
  22. #define center (((wnd->lcol - wnd->ucol) / 2) - (wrklen /2));
  23. #define wrkstr PCWRKSTR
  24.  
  25. extern char wrkstr[];
  26.  
  27. int wprints(WNDPTR *wnd,int row,int col,int fclr,int bclr, char *str) {
  28.  
  29.     int far  *scrnptr;
  30.     int      page, pagesize, attr;
  31.     int      mx_rows, mx_cols, wrklen;
  32.     unsigned offset, scrnseg;
  33.  
  34.     if (!wnd) return(0);
  35.     if (!chk_video_state(&mx_rows, &mx_cols)) return(0);
  36.     if (wnd->hideflag) return(0);
  37.  
  38.     strcpy(wrkstr,str);
  39.     wrklen = strlen(wrkstr);
  40.     if (col == CENTER) col = center;
  41.     row = row + wnd->urow;
  42.     col = col + wnd->ucol;
  43.  
  44. /*****************************************************************/
  45. /* Need to put in some code to see if string will fit into window*/
  46. /* Truncate the string if neccessary.  Two cases, if string too  */
  47. /* long to fit in window, or starting in a column where it will  */
  48. /* move out of bounds.  Also need to check if the row is valid.  */
  49. /*****************************************************************/
  50.  
  51.     if (col >= wnd->lcol) return(0);        /* Check to see if row */
  52.     if (col <= wnd->ucol) return(0);        /* Or col out of bounds */
  53.     if (row <= wnd->urow) return(0);
  54.     if (row >= wnd->lrow) return(0);
  55.     if ((wrklen + col) >= wnd->lcol)        /* If string too long then */
  56.        wrkstr[wnd->lcol - col] = '\0';      /* truncate it.            */
  57.  
  58.     re_order(wnd, NORMAL);
  59.     scrnseg = getscrnseg();
  60.     page    = wnd->page;
  61.     pagesize= getpagesize();
  62.     offset  = MK_SCRNOFF(row,col);
  63.     attr    = MK_ATTR(fclr,bclr);
  64.     scrnptr = (int far *)MK_FP(scrnseg,offset);
  65.     Tputs(scrnptr, (char far *) wrkstr, attr);
  66.     return(1);
  67. }
  68.